<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.thymeleaf.org/thymeleaf-extras-shiro">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>ComputerERP主页</title>
    <link rel="stylesheet" href="/static/js/layui/css/layui.css">
    <script type="text/javascript" src="/static/js/jquery/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="/static/js/layui/layui.js"></script>
    <script type="text/javascript" src="/static/js/echarts/echarts.min.js"></script>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <!--    上方导航栏-->
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">ComputerERP</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <!--        <ul class="layui-nav layui-layout-left">-->
        <!--            &lt;!&ndash; 移动端显示 &ndash;&gt;-->
        <!--            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">-->
        <!--                <i class="layui-icon layui-icon-spread-left"></i>-->
        <!--            </li>-->

        <!--            <li class="layui-nav-item layui-hide-xs"><a href="">nav 1</a></li>-->
        <!--            <li class="layui-nav-item layui-hide-xs"><a href="">nav 2</a></li>-->
        <!--            <li class="layui-nav-item layui-hide-xs"><a href="">nav 3</a></li>-->
        <!--            <li class="layui-nav-item">-->
        <!--                <a href="javascript:;">nav groups</a>-->
        <!--                <dl class="layui-nav-child">-->
        <!--                    <dd><a href="">menu 11</a></dd>-->
        <!--                    <dd><a href="">menu 22</a></dd>-->
        <!--                    <dd><a href="">menu 33</a></dd>-->
        <!--                </dl>-->
        <!--            </li>-->
        <!--        </ul>-->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" class="layui-nav-img">
                    tester
                </a>
                <dl class="layui-nav-child">
                    <dd><a th:href="@{/main/selfinformation}">个人信息</a></dd>
                    <dd><a href="">退出登录</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                <a href="javascript:;">
                    <i class="layui-icon layui-icon-more-vertical"></i>
                </a>
            </li>
        </ul>
    </div>
    <!--左侧导航栏-->
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item">
                    <a class="" href="javascript:;">进货管理</a>
                    <dl class="layui-nav-child">
                        <dd><a th:href="@{/main/purchase/pmanagement}">进货入库</a></dd>
                        <dd><a th:href="@{/main/purchase/omanagement}">退货出库</a></dd>
                        <dd><a th:href="@{/main/purchase/pmanagementorder}">进货单查询</a></dd>
                        <dd><a th:href="@{/main/purchase/omanagementorder}">退货单查询</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item ">
                    <a href="javascript:;">销售管理</a>
                    <dl class="layui-nav-child">
                        <dd><a th:href="@{/main/sales/salesdelivery}">销售出库</a></dd>
                        <dd><a th:href="@{/main/sales/omanagement}">客户退货</a></dd>
                        <dd><a th:href="@{/main/sales/salesorder}">销售单查询</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item ">
                    <a class="" href="javascript:;">库存管理</a>
                    <dl class="layui-nav-child">
                        <dd><a th:href="@{/main/warehouse/damage}">商品报损/报溢</a></dd>
                        <dd><a th:href="@{/main/warehouse/alarm}">库存报警</a></dd>
                        <dd><a th:href="@{/main/warehouse/brimordamage}">报损报溢查询</a></dd>
                        <dd><a th:href="@{/main/warehouse/querywarehouse}">当前库存查询</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a class="" href="javascript:;">统计报表</a>
                    <dl class="layui-nav-child">
                        <dd><a th:href="@{/main/report/business}">供应商统计报表</a></dd>
                        <dd><a th:href="@{/main/report/buyCount}">商品采购统计</a></dd>
                        <dd><a th:href="@{/main/report/saleCount}">商品销售统计</a></dd>
                        <dd><a th:href="@{/main/report/mouthCount}">月销售统计报表</a></dd>
                        <dd><a th:href="@{/main/report/yearCount}">年销售统计报表</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item ">
                    <a class="" th:href="@{/main/manage/manage}">系统设置</a>
                </li>
            </ul>
        </div>
    </div>
    <!--主体区域-->
    <!--    <div class="layui-body">-->
    <!--        &lt;!&ndash; 内容主体区域 &ndash;&gt;-->
    <!--&lt;!&ndash;        <div style="padding: 15px;">内容主体区域。记得修改 layui.css 和 js 的路径</div>&ndash;&gt;-->
    <!--    </div>-->
    <div class="layui-tab layui-tab-brief">
        <div class="layui-body layui-tab-content" style="background-image: url(/static/js/images/bg.jpg);">
            <div class="layui-tab-item layui-show">
                <div class="layui-main">
                    <div id="LAY_layedit_code">
                            <!-- 这里写主体内容-->
                        <div class="layui-col-md4">
                            <div id="businessbar" style="width: 100%;height:400px;"></div>
                        </div>
                        <div class="layui-col-md4">
                                    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
                            <div id="businesspie" style="width: 100%;height:400px;"></div>
                        </div>
                        <div class="layui-col-md4">
                            <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
                            <div id="businesspie2" style="width: 100%;height:400px;"></div>
                        </div>
                        <div class="layui-col-md8 layui-col-md-offset2">
                            <div id="businessall" style="width: 100%;height:400px;"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        底部固定区域
    </div>
</div>

<script>
    //JS
    layui.use(['element', 'layer', 'util'], function(){
        var element = layui.element
            ,layer = layui.layer
            ,util = layui.util
            ,$ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function(othis){
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
            ,menuRight: function(){
                layer.open({
                    type: 1
                    ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                    ,area: ['260px', '100%']
                    ,offset: 'rt' //右上角
                    ,anim: 5
                    ,shadeClose: true
                });
            }
        });
    });
</script>
<script type="text/javascript">
    $(function (){
        loginBusinessPie();

        // 基于准备好的dom，初始化echarts实例
        var businessbar = echarts.init(document.getElementById('businessbar'), 'light');
        var businesspie = echarts.init(document.getElementById('businesspie'), 'light');
        var businesspie2 = echarts.init(document.getElementById('businesspie2'), 'light');
        var businessall = echarts.init(document.getElementById('businessall'),'light');
        function loginBusinessPie(){
            $.ajax({
                url:"/main/report/login/business/businesspie",
                type:"post",
                datatype:"json",
                success:function (data){
                    console.log(data)
                    var names=[];
                    var successNumber=[];
                    var timeoutNumber=[];
                    var totalNumber=[];
                    var servicedata1=[];
                    var servicedata2=[];
                    var servicedata3=[];
                    for (i=0;i<data.merchants.length;i++){
                        var obj = new Object();
                        obj.name = data.merchants[i].name;
                        obj.value = data.merchants[i].successNumber;
                        servicedata1[i] = obj;
                        names[i] = obj.name;
                        successNumber[i] = obj.value;
                    }
                    for (i=0;i<data.merchants.length;i++){
                        var obj = new Object();
                        obj.name = data.merchants[i].name;
                        obj.value = data.merchants[i].timeoutNumber;
                        servicedata2[i] = obj;
                        timeoutNumber[i] = obj.value;
                    }
                    for (i=0;i<data.merchants.length;i++){
                        var obj = new Object();
                        obj.name = data.merchants[i].name;
                        obj.value = data.merchants[i].totalNumber;
                        servicedata3[i] = obj;
                        totalNumber[i] = obj.value;
                    }
                    businesspie.setOption({
                        title:{
                            text:"成功交易占比",
                            left:"center",
                            textStyle:{
                                //文字颜色
                                color:'rgb(156,220,254)',
                                //字体风格,'normal','italic','oblique'
                                fontStyle:'italic',
                                //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
                                fontWeight:'bolder',
                                //字体系列
                                fontFamily:'sans-serif',
                                //字体大小
                                fontSize:22
                            }
                        },
                        series : [
                            {
                                name: '供货商交易占比',
                                type: 'pie',    // 设置图表类型为饼图
                                radius: '60%',  // 饼图的半径，外半径为可视区尺寸（容器高宽中较小一项）的 55% 长度。
                                data:servicedata1 // 数据数组，name 为数据项名称，value 为数据项值
                            }
                        ]
                    });
                    businessbar.setOption({
                        title:{
                            text:"退单占比",
                            left:"center",
                            textStyle:{
                                //文字颜色
                                color:'rgb(156,220,254)',
                                //字体风格,'normal','italic','oblique'
                                fontStyle:'italic',
                                //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
                                fontWeight:'bolder',
                                //字体系列
                                fontFamily:'sans-serif',
                                //字体大小
                                fontSize:22
                            }
                        },
                        series : [
                            {
                                name: '供货商交易占比',
                                type: 'pie',    // 设置图表类型为饼图
                                radius: '60%',  // 饼图的半径，外半径为可视区尺寸（容器高宽中较小一项）的 55% 长度。
                                data:servicedata2 // 数据数组，name 为数据项名称，value 为数据项值
                            }
                        ]
                    });
                    businesspie2.setOption({
                        title:{
                            text:"交易总次数占比",
                            left:"center",
                            textStyle:{
                                //文字颜色
                                color:'rgb(156,220,254)',
                                //字体风格,'normal','italic','oblique'
                                fontStyle:'italic',
                                //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
                                fontWeight:'bolder',
                                //字体系列
                                fontFamily:'sans-serif',
                                //字体大小
                                fontSize:22
                            }
                        },
                        series : [
                            {
                                name: '供货商交易占比',
                                type: 'pie',    // 设置图表类型为饼图
                                radius: '60%',  // 饼图的半径，外半径为可视区尺寸（容器高宽中较小一项）的 55% 长度。
                                data:servicedata3 // 数据数组，name 为数据项名称，value 为数据项值
                            }
                        ]
                    });
                    businessall.setOption({
                        tooltip : {
                            trigger: 'axis'
                        },
                        legend: {
                            data:['交易成功数','交易超时数','交易总次数']
                        },
                        toolbox: {
                            show : true,
                            feature : {
                                mark : {show: true},
                                // dataView : {show: true, readOnly: false},
                                magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
                                restore : {show: true},
                                saveAsImage : {show: true}
                            }
                        },
                        calculable : true,
                        xAxis : [
                            {
                                type : 'category',
                                boundaryGap : false,
                                data : names
                            }
                        ],
                        yAxis : [
                            {
                                type : 'value'
                            }
                        ],
                        series : [
                            {
                                name:'交易成功数',
                                type:'line',
                                stack: '总量',
                                data:successNumber
                            },
                            {
                                name:'交易超时数',
                                type:'line',
                                stack: '总量',
                                data:timeoutNumber
                            },
                            {
                                name:'交易总次数',
                                type:'line',
                                stack: '总量',
                                data:totalNumber
                            },
                        ]
                    });
                }
            });
        }
    });
</script>
</body>
</html>